angular.module('app').controller('chongzhiCtrl', 
['$scope', '$rootScope', 'http', 'stateV', '$state',
function($scope, $rootScope, http, stateV, $state) 
{
	$scope.query = {pages:0, total:0, totalPages:0};
	$scope.collect = {
		prePage: function(){
			if($scope.query.pages >= 1){
				--$scope.query.pages
				list();
			}
		},
		nextPage: function(){
			if(($scope.query.pages+1) < $scope.query.totalPages){
				++$scope.query.pages
				list();
			}
		},
		showPage: function(num){
			if((switchPage($scope.query.pages) + num) < $scope.query.totalPages)
				return true
			else
				return false
		},
		showPageVal: function(num){
			return switchPage($scope.query.pages) + num;
		}
	};

	// 确认订单
	$scope.confirm = function(orderid){
		http.post('/bbalance/confirmChong', {orderid: orderid}, function(data, status){
			if(data){
				list()
			}
		})
	}

	// 关闭订单
	$scope.guanbi = function(orderid){
		http.post('/bbalance/excpChong', {orderid: orderid}, function(data, status){
			if(data){
				list()
			}
		})
	}
	

	function list(){
		http.post('/bbalance/chonglist', $scope.query, function(data, status){
			$scope.query.total = data.count;
			$scope.query.totalPages = totalPage($scope.query.total);
			$scope.datalist = data.list; 
			console.log($scope.datalist)
		})
	}

	list();
	
	
}]);